<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@page import="java.lang.System"%>
<%@page import="java.util.Calendar"%>
<%@page import="java.util.ArrayList"%>
<%@page import="org.dinnermate.menu.Menu"%>
<%@page import="org.dinnermate.menu.MenuItem"%>
<%@page import="net.java.ao.EntityManager"%>
<%@page import="org.dinnermate.db.DBManager"%>

<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/AllPages.css">
	</head>
	<body>
		<table>
			<%
				long today = Calendar.getInstance().getTimeInMillis();
				// Get array of menu items from the db.
				EntityManager manager = DBManager.getEntityManager();
				Menu menus[] = manager.find(Menu.class);
				Menu currentMenu = null;
				
				for (int i = 0; i < menus.length; i++)
				{
					if ((menus[i].getStartDate() < today) && (today < menus[i].getEndDate()))
					{
						currentMenu = menus[i];
						break;
					}
				}
				MenuItem items[] = null;
				if (currentMenu != null)
				{
					items = currentMenu.getMenuItems();
					
					for (int i = 0; i < menus.length; i++)
					{
						System.out.println(items[i].getName());
					}
				}
			%>
		</table>
	</body>
</html>